package com.dog.basics.common.photooss.configuration;


import com.dog.basics.common.photooss.properties.AliyunOSSProperties;
import com.dog.basics.common.photooss.service.PhotoOssUtil;
import com.dog.basics.common.photooss.service.impl.AliyunPhotoOssUtil;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program: business
 * @description:  判断是阿里云上传则直接注入
 * @author: Guo
 * @create: 2020-02-06 16:25
 **/
@AllArgsConstructor
@Configuration
@ConditionalOnClass(PhotoOssUtil.class)
@EnableConfigurationProperties({AliyunOSSProperties.class})
@ConditionalOnProperty(name = "flag", havingValue = "true")
public class AliyunPhotoConfiguration {

	/**
	 * 配置信息
	 */
	private final AliyunOSSProperties aliyunOSSProperties;


	/**
	 * Bean 阿里云OSS上传
	 * @return
	 */
	@Bean
	//@ConditionalOnProperty(name = "photo-oss.component", havingValue = "AliyunOSS")
	PhotoOssUtil aliyunPhotoOssUtil() {
		AliyunPhotoOssUtil aliyunPhotoOssUtil = new AliyunPhotoOssUtil(aliyunOSSProperties);
		return aliyunPhotoOssUtil;
	}
}
